package com.dk.service.impl;

import com.dk.mapper.TbBailMapper;
import com.dk.mapper.TbOrderMapper;
import com.dk.service.TbBailService;
import com.dk.vo.TbBailVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class TbBailServiceImpl implements TbBailService {

    @Autowired
    private TbOrderMapper tbOrderMapper;

    @Autowired
    private TbBailMapper tbBailMapper;

    @Override
    public String insert(Long userid, Long cid, Long num) {

        String i = tbOrderMapper.selectStatus(userid, cid, num);
        if (i.equals("2")) {//已付款
            tbBailMapper.insertAll(userid, cid, num);
            return i;
        }
        return i;
    }

    @Override
    public TbBailVO selectBailByUid(Long userid) {
        return tbBailMapper.selectByUserId(userid);
    }
}
